package com.jhy.finance;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Description:
 * @authoer:jihaiyu
 * @date: 2017/6/29 10:32
 */
public class SYJS {
    public static void main(String[] args) {
        System.out.println(getIncome(new BigDecimal(10000), 365, new BigDecimal(0.15), 14));
    }

    /**
     * @param investAmount    投资额
     * @param incomeCalcBasis 收益计算基础 365/360
     * @param expAror         预期年化收益率
     * @param T               投资周期
     * @return
     */
    public static BigDecimal getIncome(BigDecimal investAmount, int incomeCalcBasis, BigDecimal expAror, int T) {
        BigDecimal income = BigDecimal.ZERO;
        if(investAmount == null || incomeCalcBasis <= 0 || expAror == null)
            return income;

        if(T <= 0)
            T = 1;

        income = investAmount.multiply(expAror).divide(new BigDecimal(incomeCalcBasis), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(T));
        return income;
    }
}
